<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改人员')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<div class="form-group draggable" style="padding-left:15px">
		心率阈值：
		</div>
		<div class="form-group draggable" style="padding-left:15px">
		<div class="form-group">
				<label>下限：</label>
					<input  id="heartMin" name="heartMin"  type="text" th:field="*{alarmRuleConfig.heartMin}" style="width: 50px">
				<label>  上限：</label>
					<input id="heartMax" name="heartMax"  type="text"  th:field="*{alarmRuleConfig.heartMax}" style="width: 50px">
		</div>
		</div>
		<div class="form-group draggable">
			<label class="col-sm-3 control-label">报警启动：</label>

			<div class="col-sm-9">
				<label class="check-box">
					<input type="checkbox" name= "alarm" value="1" th:checked="*{alarmRuleConfig.sosAlarm}" id="sosAlarm">SOS报警</label>
				<label class="check-box">
					<input type="checkbox" name= "alarm" value="2" th:checked="*{alarmRuleConfig.removeAlarm}" id="removeAlarm">摘除报警</label>
				<label class="check-box">
					<input type="checkbox" name= "alarm" value="3" th:checked="*{alarmRuleConfig.heartRateAlarm}"  id="heartRateAlarm">心率报警</label>
				<label class="check-box">
					<input type="checkbox" name= "alarm" value="4" th:checked="*{alarmRuleConfig.lowVoltageAlarm}"id="lowVoltageAlarm">低电报警</label>
				<label class="check-box">
					<input type="checkbox" name= "alarm" value="5" th:checked="*{alarmRuleConfig.areaAlarm}" id="areaAlarm">区域报警</label>
			</div>
		</div>
    </div>
	<th:block th:include="include :: footer" />
	<script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
	<script th:src="@{/ajax/libs/beautifyhtml/beautifyhtml.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "system/tagAlarmData";
		$(function(){
			$('input:not([autocomplete]),textarea:not([autocomplete]),select:not([autocomplete])').attr('autocomplete', 'off');
		});
		$("#form-tagAlarmData-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});
		function submitHandler() {
			var heartMin = $("#heartMin").val();
			var heartMax = $("#heartMax").val();
			var sosAlarm=0;
			var removeAlarm=0;
			var heartRateAlarm=0;
			var lowVoltageAlarm=0;
			var areaAlarm=0;
			var str = $.form.selectCheckeds("alarm");
			var alarms = str.split(',');
			if (alarms.length>0){
				for (i=0;i<alarms.length;i++){
					switch (alarms[i]) {
						case "1":
							sosAlarm=1;
							break;
						case "2":
							removeAlarm=1;
							break;
						case "3":
							heartRateAlarm=1;
							break;
						case "4":
							lowVoltageAlarm=1;
							break;
						case "5":
							areaAlarm=1;
							break;
					}
				}
			}
			var data={
				id:1,
				sosAlarm:sosAlarm,
				removeAlarm:removeAlarm,
				heartRateAlarm:heartRateAlarm,
				lowVoltageAlarm:lowVoltageAlarm,
				areaAlarm:areaAlarm,
				heartMin:heartMin,
				heartMax:heartMax
			}
			var url = prefix+"/editRule";
			var config = {
				url: url,
				type: "post",
				dataType: "json",
				data: data,
				beforeSend: function () {
					$.modal.loading("正在处理中，请稍后...");
					$.modal.disable();
				},
				success: function(result) {

					$.operate.successCallback(result);
				}
			};
			$.ajax(config)
	    }
	</script>
</body>
</html>
